<?php

/**
 * Paciente form base class.
 *
 * @method Paciente getObject() Returns the current form's model object
 *
 * @package    gnlab
 * @subpackage form
 * @author     Miguel Barocchi
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BasePacienteForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'            => new sfWidgetFormInputHidden(),
      'obrasocial_id' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('ObraSocial'), 'add_empty' => false)),
      'categoria_id'  => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Categoria'), 'add_empty' => true)),
      'grado_id'      => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Grado'), 'add_empty' => true)),
      'unidad_id'     => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Unidad'), 'add_empty' => true)),
      'afiliado_id'   => new sfWidgetFormInputText(),
      'nombre'        => new sfWidgetFormInputText(),
      'apellido'      => new sfWidgetFormInputText(),
      'sexo'          => new sfWidgetFormInputCheckbox(),
      'fecha_nac'     => new sfWidgetFormDate(),
      'dni'           => new sfWidgetFormInputText(),
      'ce'            => new sfWidgetFormInputText(),
      'created_at'    => new sfWidgetFormDateTime(),
      'updated_at'    => new sfWidgetFormDateTime(),
    ));

    $this->setValidators(array(
      'id'            => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'obrasocial_id' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('ObraSocial'))),
      'categoria_id'  => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Categoria'), 'required' => false)),
      'grado_id'      => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Grado'), 'required' => false)),
      'unidad_id'     => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Unidad'), 'required' => false)),
      'afiliado_id'   => new sfValidatorString(array('max_length' => 31)),
      'nombre'        => new sfValidatorString(array('max_length' => 31)),
      'apellido'      => new sfValidatorString(array('max_length' => 31)),
      'sexo'          => new sfValidatorBoolean(),
      'fecha_nac'     => new sfValidatorDate(),
      'dni'           => new sfValidatorString(array('max_length' => 15)),
      'ce'            => new sfValidatorString(array('max_length' => 31, 'required' => false)),
      'created_at'    => new sfValidatorDateTime(),
      'updated_at'    => new sfValidatorDateTime(),
    ));

    $this->widgetSchema->setNameFormat('paciente[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Paciente';
  }

}
